<template>
<!-- pages/merchant/merchant.wxml -->
<view class="merchant">
    <view class="merchant_head" :style="'padding-top:' + statusBarHeight + 'px'">
        <view class="head_dateTime">
            <text class="head_day">{{time.date > 9 ? time.date : '0' + time.date}}</text>
            <view class="head_date">
                <text class="head_week">{{time.day}}</text>
                <text class="head_time">{{time.year}}年{{time.month}}月</text>
            </view>
        </view>
        <view class="head_info">
            <image class="info_avatar" :src="memberInfo.head_image"></image>
            <text class="info_name">{{memberInfo.nickname}}</text>
        </view>
    </view>
    <view class="management">
        <view class="management_item merchant_item" @tap="toCommodityManagement">
            <view class="item_info">
                <text class="info_txt">商家管理</text>
                <image class="info_icon merchant_icon" src="/static/pages/image/merchant_icon.png"></image>
            </view>
            <text class="txt">发布商品 管理商品</text>
        </view>
        <view class="management_item order_item" @tap="toOrderManagement">
            <view class="item_info">
                <text class="info_txt">订单管理</text>
                <image class="info_icon order_icon" src="/static/pages/image/order_icon.png"></image>
            </view>
            <text class="txt">发布商品 管理商品</text>
        </view>
    </view>
    <view class="other_functions">
        <view class="other_title">
            <view class="title_line"></view>
            <text class="title_txt">其它功能</text>
        </view>
        <view class="other_content">
            <button class="other_item">
                <image class="other_icon service_icon" src="/static/pages/image/service_icon.png"></image>
                <view class="other_txt">联系客服</view>
            </button>
            <button class="other_item" @click="toSetings">
                <image class="other_icon seting_icon" src="/static/pages/image/seting_icon.png"></image>
                <view class="other_txt">我的设置</view>
            </button>
        </view>
    </view>
    <view class="footer">
        <view class="footer_item">
            <image class="footer_icon mall_icon" src="/static/pages/image/yulan_icn.png"></image>
            <view class="footer_txt">商家</view>
        </view>
        <view class="footer_item" @tap="onBack">
            <image class="footer_icon seting_icon" src="/static/pages/image/fenxi0ang.png"></image>
            <view class="footer_txt">返回</view>
        </view>
    </view>
</view>
</template>

<script>
// pages/merchant/merchant.js
var app = getApp();

export default {
  data() {
    return {
      statusBarHeight: 0,
      time: {
        year: '',
        month: '',
        date: '',
        day: ''
      },
      memberInfo: {},
      day_list: ['周天', '周一', '周二', '周三', '周四', '周五', '周六']
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getSystemInfo();
    this.getTime();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getUserInfo();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
	  toSetings(){
		uni.navigateTo({
		  url: '/pagesA/mySettings/mySettings'
		});
	  },
    getTime() {
      var date = new Date();
      let time = {
        year: date.getFullYear(),
        month: date.getMonth() + 1,
        date: date.getDate(),
        day: this.day_list[date.getDay()]
      };
      this.setData({
        time
      });
    },

    getUserInfo() {
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "me.detail",
          uid: wx.getStorageSync('uid')
        },
        success: e => {
          this.setData({
            memberInfo: e.data.data.user
          });
        }
      });
    },

    // 返回
    onBack() {
      wx.navigateBack();
    },

    toOrderManagement() {
      wx.navigateTo({
        url: '/pagesA/orderManagement/orderManagement'
      });
    },

    toCommodityManagement() {
      wx.navigateTo({
        url: '/pagesA/commodityManagement/commodityManagement'
      });
    },

    getSystemInfo() {
      wx.getSystemInfo({
        success: res => {
          this.setData({
            statusBarHeight: res.statusBarHeight
          });
        }
      });
    }

  }
};
</script>
<style>
@import "./merchant.css";
</style>